package com.ruoyi.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wms.domain.WmsInventoryMovement;
import com.ruoyi.wms.service.IWmsInventoryMovementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存移动Controller
 *
 * @author zmm
 * @date 2023-01-30
 */
@RestController
@RequestMapping("/wms/inventoryMovement")
public class WmsInventoryMovementController extends BaseController
{
    @Autowired
    private IWmsInventoryMovementService wmsInventoryMovementService;

    /**
     * 查询库存移动列表
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsInventoryMovement wmsInventoryMovement)
    {
        startPage();
        List<WmsInventoryMovement> list = wmsInventoryMovementService.selectWmsInventoryMovementList(wmsInventoryMovement);
        return getDataTable(list);
    }

    /**
     * 导出库存移动列表
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:export')")
    @Log(title = "库存移动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInventoryMovement wmsInventoryMovement)
    {
        List<WmsInventoryMovement> list = wmsInventoryMovementService.selectWmsInventoryMovementList(wmsInventoryMovement);
        ExcelUtil<WmsInventoryMovement> util = new ExcelUtil<WmsInventoryMovement>(WmsInventoryMovement.class);
        util.exportExcel(response, list, "库存移动数据");
    }

    /**
     * 获取库存移动详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wmsInventoryMovementService.selectWmsInventoryMovementById(id));
    }

    /**
     * 新增库存移动
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:add')")
    @Log(title = "库存移动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInventoryMovement wmsInventoryMovement)
    {
        wmsInventoryMovement.setCreateBy(getUserIdStr());
        return toAjax(wmsInventoryMovementService.insertWmsInventoryMovement(wmsInventoryMovement));
    }

    /**
     * 修改库存移动
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:edit')")
    @Log(title = "库存移动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInventoryMovement wmsInventoryMovement)
    {
        wmsInventoryMovement.setUpdateBy(getUserIdStr());
        return toAjax(wmsInventoryMovementService.updateWmsInventoryMovement(wmsInventoryMovement));
    }

    /**
     * 删除库存移动
     */
    @PreAuthorize("@ss.hasPermi('wms:inventoryMovement:remove')")
    @Log(title = "库存移动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsInventoryMovementService.deleteWmsInventoryMovementByIds(ids));
    }
}
